package com.behome.netty.netty_B.bean;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * TerminalRecord
 *
 * @author bh_ljy
 * @version 2024/05/27 10:49
 **/
@Data
public class BroadcastRecords {
    private short channelId;
    private byte broadcastStatus;
    private String ebmId;
    private byte taskType;
    private byte broadcastType;
    private byte eventLevel;
    private String eventType;
    private Date beginTime;
    private Date endTime;
    private byte phoneLength = 0;
    private String phone;
    private byte volume;
    private byte resourceCodeCount;
    private byte resourceCodeLength = 12;
    private String[] resourceCodes;
    private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public String toCHJsonString() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.putOnce("通道号", this.channelId);
        jsonObject.putOnce("播发状态", this.broadcastStatus);
        jsonObject.putOnce("广播编号", this.ebmId);
        jsonObject.putOnce("任务类型", this.taskType);
        jsonObject.putOnce("广播类型", this.broadcastType);
        jsonObject.putOnce("事件级别", this.eventLevel);
        jsonObject.putOnce("事件类型", this.eventType);
        jsonObject.putOnce("开始时间", this.dateFormat.format(this.beginTime));
        jsonObject.putOnce("结束时间", this.dateFormat.format(this.endTime));
        jsonObject.putOnce("电话号码", this.phone);
        jsonObject.putOnce("音量", this.volume);
        jsonObject.putOnce("覆盖区域数量", this.resourceCodeCount);
        JSONArray jsonArray = new JSONArray();
        if (this.resourceCodes != null) {
            for (String resourceCode : this.resourceCodes) {
                jsonArray.put(resourceCode);
            }
        }
        jsonObject.putOnce("覆盖区域编码集合", jsonArray);
        return jsonObject.toString();
    }

}
